export enum ApiMethod {
  GET = "GET",
  POST = "POST",
  PUT = "PUT",
  DELETE = "DELETE",
}

export enum ApiStatus {
  Disabled = 0,
  Enabled = 1,
}

export enum ApiType {
  DataSource = "DataSource", // 数据源类型
  REST = "REST", // 外部REST类型
}

// SQL配置
export interface SqlConfig {
  sql: string;
  params?: Record<string, any>;
}

// REST配置
export interface RestConfig {
  url: string;
  method: ApiMethod;
  headers?: Record<string, string>;
  params?: Record<string, any>;
  body?: string;
}

export interface ApiConfig {
  id?: number;
  name: string;
  path: string;
  method: ApiMethod;
  type: ApiType; // API类型
  status: ApiStatus;
  description?: string;
  dataSourceId?: number; // 数据源ID（当type为DataSource时必填）
  config: SqlConfig | RestConfig; // 具体配置
  requestSchema?: string; // 请求参数schema
  responseSchema?: string; // 响应结构schema
  createdAt?: string;
  updatedAt?: string;
}

export interface ApiQuery {
  keyword?: string;
  page: number;
  pageSize: number;
}

export interface ApiResponse {
  list: ApiConfig[];
  total: number;
}
